package me.zhengjie.modules.biz.rest;

import cn.hutool.json.JSONArray;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.AnonymousAccess;
import me.zhengjie.annotation.Log;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequiredArgsConstructor
@Api(tags = "热图管理")
@RequestMapping("/api/hot")
public class HotController {

    @AnonymousAccess
    @GetMapping("/3d/detail")
    @Log("查询某一层热图信息")
    @ApiOperation("查询某一层热图信息")
    public ResponseEntity<Object> queryHot(@RequestParam Integer floor) {

        List<Map<String, Object>> details = new ArrayList<>();
        Map<String, Object> temMap = new HashMap<>();
        Map<String, Object> preMap = new HashMap<>();
        Map<String, Object> humMap = new HashMap<>();
        Map<String, Object> vocMap = new HashMap<>();
        JSONArray temArray = new JSONArray();
        JSONArray preArray = new JSONArray();
        JSONArray humArray = new JSONArray();
        JSONArray vocArray = new JSONArray();

        if (floor.equals(1)) {
            temMap.put("title", "温度");
            temMap.put("value", 40);
            temArray.add(15);
            temArray.add(25);
            temArray.add(35);
            temArray.add(45);
            temArray.add(55);
            temMap.put("value_arr", temArray);
            details.add(temMap);

            preMap.put("title", "压力");
            preMap.put("value", 40);
            preArray.add(0);
            preArray.add(30);
            preArray.add(60);
            preArray.add(90);
            preArray.add(120);
            preMap.put("value_arr", preArray);
            details.add(preMap);

            humMap.put("title", "湿度");
            humMap.put("value", 20);
            humArray.add(15);
            humArray.add(25);
            humArray.add(35);
            humArray.add(45);
            humArray.add(55);
            humMap.put("value_arr", humArray);
            details.add(humMap);

            vocMap.put("title", "VOC");
            vocMap.put("value", 33);
            vocArray.add(15);
            vocArray.add(25);
            vocArray.add(35);
            vocArray.add(45);
            vocArray.add(55);
            vocMap.put("value_arr", vocArray);
            details.add(vocMap);

        } else if (floor.equals(2)) {

        }

        return new ResponseEntity<>(details, HttpStatus.OK);
    }
}
